package com.gage.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gage.commons.result.BaseConditionVO;
import com.gage.commons.result.Tree;
import com.gage.mapper.SysAccessoryMapper;
import com.gage.mapper.SysAlbumMapper;
import com.gage.model.SysAccessory;
import com.gage.model.SysAlbum;
import com.gage.service.ISysAblumService;
@Transactional(rollbackFor = Exception.class)
@Service
public class SysAblumServiceImpl implements ISysAblumService{
	@Autowired
	private SysAlbumMapper sysAlbumMapper;
	@Autowired
	private SysAccessoryMapper sysAccessoryMapper;
	@Override
	public Object selectAlbumTree(Integer userId) {
		 List<Tree> trees = new ArrayList<Tree>();
	        List<SysAlbum> sysAlbums =sysAlbumMapper.selectAlbumByuserId(userId);
	        for (SysAlbum sysAlbum : sysAlbums) {
	            Tree tree = new Tree();
	            tree.setId(Long.parseLong(sysAlbum.getId().toString()));
	            tree.setText(sysAlbum.getAlbumName());
	            tree.setIconCls("fi-folder");
	            trees.add(tree);
	        }
	        return trees;
	}
	@Override
	public int deleteByPrimaryKey(Integer id) {
		return sysAlbumMapper.deleteByPrimaryKey(id);
	}
	@Override
	public int insertSelective(SysAlbum record) {
		// TODO Auto-generated method stub
		return sysAlbumMapper.insertSelective(record);
	}
	@Override
	public SysAlbum selectByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return sysAlbumMapper.selectByPrimaryKey(id);
	}
	@Override
	public List<SysAlbum> selectAlbumByuserId(Integer userId) {
		// TODO Auto-generated method stub
		return sysAlbumMapper.selectAlbumByuserId(userId);
	}
	@Override
	public int updateByPrimaryKeySelective(SysAlbum record) {
		// TODO Auto-generated method stub
		return sysAlbumMapper.updateByPrimaryKeySelective(record);
	}
	@Override
	public int insertSysAccessory(SysAccessory record) {
		int i=sysAccessoryMapper.insertSelective(record);
		return i;
	}
	@Override
	public List<SysAccessory> selectImageList(BaseConditionVO vo,String albumId,String userId) {
		RowBounds rb = new RowBounds(vo.getStartIndex(), vo.getRows());
		return sysAccessoryMapper.selectImageList(rb, albumId, userId);
	}
	@Override
	public int selectImageListCount(String albumId,String userId) {
		// TODO Auto-generated method stub
		return sysAccessoryMapper.selectImageListCount(albumId,userId);
	}
	@Override
	public Integer deleteByIds(List<String> ids) {
		return sysAccessoryMapper.deleteByIds(ids);
	}
	@Override
	public SysAccessory selectAccessoryByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return sysAccessoryMapper.selectByPrimaryKey(Long.parseLong(id.toString()));
	}
	@Override
	public int updateSysAccessoryById(SysAccessory record) {
		// TODO Auto-generated method stub
		return sysAccessoryMapper.updateByPrimaryKeySelective(record);
	}

}
